package cn.sptpc.servlet;

import cn.sptpc.service.GroupService;
import cn.sptpc.service.impl.GroupServiceI;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/GroupsServlet")
public class GroupsServlet extends HttpServlet {
    private GroupService service = new GroupServiceI();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json;charset=gbk");
        int departmentId =Integer.parseInt(request.getParameter("departmentId")) ;
        String allGroupByDeparment = service.getAllGroupByDeparment(departmentId);
        response.getWriter().write(allGroupByDeparment);
    }
}
